package whf.framework.util;

import whf.framework.exception.PropertyException;
import whf.framework.meta.entity.IProperty;

/**
 * @author king
 * @create 2008-1-21 上午09:30:03
 * 
 */
public class PropertyUtils {
	private PropertyUtils(){
		//
	}
	
	public static Object translateProperty(Object value, IProperty prop) throws PropertyException {
		String property = prop == null? null:prop.getName();
		if(prop != null){
			try{
				return BeanUtils.translatePropertyToString(value, prop);
			}catch(Exception e){
				return null;
			}
		} else if(!StringUtils.isEmpty(property)){
			return BeanUtils.getSimpleProperty(value, property);
		} else{
			return null;
		}
	}
}
